package cn.hushi.test;

import cn.hushi.domain.Customer;
import cn.hushi.utils.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class Demo1 {
    public static void main(String[] args) {
        Demo1 demo1 = new Demo1();
        demo1.test1();
    }
        public void test1(){
            Customer customer =new Customer();
            customer.setName("苍老师");
            customer.setAge(18);
            customer.setGender("girl");
            customer.setLevel("顶级");
            //获取hibernate的session
            Session session = HibernateUtil.getSession();
            //创建事务,开启事务
            Transaction tx = session.beginTransaction();
            //添加操作
            session.save(customer);
            //提交事务
            tx.commit();
            //资源关闭
            session.close();


        }
}